<script>
$(document).ready(function() {
    //prepare the dialog
	
    $( "#thanhcong" ).dialog({
		title: "Thông báo",
        autoOpen: false,
        show: {
            effect: "blind",
            duration: 500
            },
        hide: {
            effect: "blind",
            duration: 500
            },
        modal: true,
		buttons: {
			 "Ok": function() {
				location.reload();
				 $('#thanhcong').dialog('close');
			}
		 }
        });	
		
	$(".close_addservice").click(function(event) {
				$('#dialogModal').dialog('close');
			});
    });
</script>

	<?php echo $this->Form->create('Salary',array('controller'=>'users','action'=>'salary_receive')); ?>
	<div class="row">
		<label>Nhân viên</label>
		<?php echo $salary['User']['name'];?>
	</div>
	<div class="row">
		<label>Mức lương</label>
		<?php
		$luong = $this->requestAction('users/format_price/'.$salary['User']['salary']);
		echo $luong;?>
	</div>
	<div class="row">
		<label>Phụ cấp</label>
		<?php 
		$phucap = $this->requestAction('users/format_price/'.$salary['Salary']['phucap']);
		echo $phucap;?>
	</div>
	<div class="row">
		<label>Tạm ứng</label>
		<?php 
		$tamung = $this->requestAction('users/format_price/'.$salary['Salary']['tamung']);
		echo $tamung;?>
	</div>
	<div class="row">
		<label>Khấu trừ</label>
		<?php 
		$khautru = $this->requestAction('users/format_price/'.$salary['Salary']['khautru']);
		echo $khautru;
		?>
	</div>
	<div class="row">
		<label>Số ngày nghỉ</label>
		<?php echo $salary['Salary']['ngaynghi'];?>
	</div>
	<div class="row">
		<label>Còn lại</label>
		<?php 
		$tiennghi = $salary['User']['salary']/30*$salary['Salary']['ngaynghi'];
		$conlai = $salary['User']['salary']+$salary['Salary']['phucap']-$salary['Salary']['tamung']-$salary['Salary']['khautru']-$tiennghi;
		
		echo $this->requestAction('users/format_price/'.$conlai);
		?>
		
	</div>
	<div class="row">
		<?php echo $this->Form->input('traluong',array('type'=>'checkbox','label'=>'Thanh toán lương', 'style'=>'max-width:256px;','div'=>false));?>
				
	</div>
		<div class="btn-dialog">
			
			<?php 
			echo $this->Js->submit('Ok', array(  //create 'ajax' save button
				'update' => '#contentWrap','div'=>false  //id of DOM element to update with selector
				));
			if (2 == $saved){ //will only be true if saved OK in controller from ajax save above
				echo "<script>
					$('#thanhcong').dialog('open');  //close containing dialog 
				</script>";
				}elseif(0 == $saved){
				echo "<script>
					$('#dialogModal').dialog('close');  //close containing dialog 
				</script>";
				}
			echo $this->Form->end();
			echo $this->Js->writeBuffer();
			?>

			<input type="button" value="Cancel" class="close_addservice">
		</div>

<div id="thanhcong" title="Thông báo">
<p align="center">Đã thanh toán lương thành công</p>
</div>